#include "begin.h"
#include "ui_begin.h"
#include "mainwindow.h"
#include "infrom.h"
#include <string>
#include <QString>
#include "mail.h"
#include "QMessageBox"
#include "QTextStream"
#include "QFile"
#include "checkmail.h"
#include "sendmail.h"

begin::begin(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::begin)
{
    ui->setupUi(this);
}

begin::~begin()
{
    delete ui;
}

void begin::on_pushButton_clicked()
{
    begin b;
    infrom m;
    m.exec();

}

void begin::on_pushButton_3_clicked()
{
    begin b;
    int argc = 3;
    char* argv[10];
    argv[0]="myemail ";
    argv[1]="list";
    argv[2]="100";
    int flag = fx(argc,argv);

    char buf[100];
    GetModuleFileNameA(NULL, buf, 100);
    string t = string(buf);
    string PATH = t.substr(0, t.rfind('\\'))+"\\list.txt";
    QString qpath=QString ::fromStdString (PATH);

    QFile *file=new QFile(qpath);
    file->open(QIODevice::ReadOnly);
    QTextStream in(file);

    ui->textBrowser->setText(in.readAll());
    file->close();
}

void begin::on_pushButton_4_clicked()
{
    checkMail m;
    m.exec();
}

void begin::on_pushButton_2_clicked()
{
    SendMail s;
    s.exec();
}
